<!DOCTYPE html>
<html lang="zh-cn">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    
    <title>如何使用 Hugo 创建博客 | liuz2&#39;s Blog</title>
    <meta name="viewport" content="width=device-width,minimum-scale=1">
    <meta name="generator" content="Hugo 0.63.1" />
    
    
      <META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
    

    
    
      <link href="/dist/css/app.9576afd3b3c158d98f48ec5df01fec6a.css" rel="stylesheet">
    

    

    
      

    

    

    <meta property="og:title" content="如何使用 Hugo 创建博客" />
<meta property="og:description" content="The world&rsquo;s fastest framework for building websites" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://liuz2.gitee.io/posts/hugo-usage/" />
<meta property="article:published_time" content="2020-06-19T22:28:13+08:00" />
<meta property="article:modified_time" content="2020-06-19T22:28:13+08:00" />
<meta itemprop="name" content="如何使用 Hugo 创建博客">
<meta itemprop="description" content="The world&rsquo;s fastest framework for building websites">
<meta itemprop="datePublished" content="2020-06-19T22:28:13&#43;08:00" />
<meta itemprop="dateModified" content="2020-06-19T22:28:13&#43;08:00" />
<meta itemprop="wordCount" content="69">



<meta itemprop="keywords" content="go," /><meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="如何使用 Hugo 创建博客"/>
<meta name="twitter:description" content="The world&rsquo;s fastest framework for building websites"/>

	
  </head>

  <body class="ma0 avenir bg-white">

    
   
  

  <header>
    <div class="bg-black">
      <nav class="pv3 ph3 ph4-ns" role="navigation">
  <div class="flex-l justify-between items-center center">
    <a href="/" class="f3 fw2 hover-white no-underline white-90 dib">
      
        liuz2&#39;s Blog
      
    </a>
    <div class="flex-l items-center">
      

      
        <ul class="pl0 mr3">
          
          <li class="list f5 f4-ns fw4 dib pr3">
            <a class="hover-white no-underline white-90" href="/about/" title="About page">
              About
            </a>
          </li>
          
          <li class="list f5 f4-ns fw4 dib pr3">
            <a class="hover-white no-underline white-90" href="/links/" title="Links page">
              Links
            </a>
          </li>
          
          <li class="list f5 f4-ns fw4 dib pr3">
            <a class="hover-white no-underline white-90" href="/timeline/" title="Timeline page">
              Timeline
            </a>
          </li>
          
        </ul>
      
      















    </div>
  </div>
</nav>

    </div>
  </header>



    <main class="pb7" role="main">
      
  
  <article class="flex-l flex-wrap justify-between mw8 center ph3">
    <header class="mt4 w-100">
      <h1 class="f3 athelas mt3 mb1">如何使用 Hugo 创建博客</h1>
      
      
      <time class="f6 mv1 dib tracked" datetime="2020-06-19T22:28:13&#43;08:00">June 19, 2020</time>

      
      
    </header>
    <div class="nested-copy-line-height lh-copy sans-serif f5 nested-links nested-img mid-gray pr4-l w-two-thirds-l"><p>Hugo 自称“世上最快的网站构建框架”。下面来学习如何使用它。</p>
<p>安装</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sh" data-lang="sh">$ brew install hugo

<span style="color:#75715e"># 验证是否安装成功</span>
$ hugo version
</code></pre></div><p>生成站点</p>
<pre><code class="language-shy" data-lang="shy">$ hugo new site /path/to/site
</code></pre><p>安装主题</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sh" data-lang="sh">$ git submodule add https://github.com/budparr/gohugo-theme-ananke.git themes/ananke

<span style="color:#75715e"># 设置主题</span>
$ echo <span style="color:#e6db74">&#39;theme = &#34;ananke&#34;&#39;</span> &gt;&gt; config.toml
</code></pre></div><p>创建关于页面</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sh" data-lang="sh">$ hugo new about.md
</code></pre></div><p>创建文章</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sh" data-lang="sh">$ hugo new posts/first.md
</code></pre></div><p>运行本地服务器，并开启草稿：</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sh" data-lang="sh">$ hugo server -D
</code></pre></div><p>构建</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sh" data-lang="sh">$ hugo -D
</code></pre></div><h2 id="参考资料">参考资料</h2>
<ol>
<li><a href="https://gohugo.io/" title="Hugo">The world&rsquo;s fastest framework for building websites | Hugo</a></li>
<li><a href="https://gohugo.io/getting-started/quick-start/" title="Quick Start">Quick Start with Hugo</a></li>
<li><a href="https://gitee.com/help/articles/4136" title="码云 Pages">码云 Pages</a></li>
</ol>
<a href="https://gitee.com/liuz2/liuz2/blob/master/content/posts/hugo-usage.md#tree_comm_title" class="no-underline db b--black pa2 tc bg-black-90" style="color:#eee;">进入留言</a><ul class="pa0">
  
   <li class="list dib">
     <a href="/tags/go" class="link f5 grow no-underline br-pill ba ph3 pv2 mb2 dib black sans-serif">go</a>
   </li>
  
</ul>
<div class="mt6 instapaper_ignoref">
      
      
      </div>
    </div>

    <aside class="w-30-l mt6-l">




</aside>

  </article>

    </main>
    <footer class="bg-black bottom-0 w-100 pa3" role="contentinfo">
  <div class="flex justify-between">
  <a class="f4 fw4 hover-white no-underline white-70 dn dib-ns pv2 ph3" href="https://liuz2.gitee.io/" >
    &copy;  liuz2's Blog 2022 
  </a>
    <div>














</div>
  </div>
</footer>

    

  <script src="/dist/js/app.3fc0f988d21662902933.js"></script>


  </body>
</html>
